<%--
  Created by IntelliJ IDEA.
  User: 27872
  Date: 2025/6/26
  Time: 10:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>组织管理系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <style>
        /* 基础样式重置 */
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f8f9fa;
        }

        /* 导航菜单容器 */
        .header {
            background: linear-gradient(135deg, #4e73df 0%, #224abe 100%);
            color: white;
            padding: 15px 30px; /* 增加左右内边距 */
            border-radius: 10px 10px 0 0;
            margin-bottom: 20px;
            display: flex;
            justify-content: space-between; /* 关键修改 */
            align-items: center; /* 垂直居中 */
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        /* 导航项样式 */
        .header h2 {
            display: flex;
            align-items: center;
            margin: 0;
            padding: 10px 20px;
            border-radius: 6px;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        /* 导航链接样式 */
        .header h2 a {
            color: white;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 1.1rem;
            font-weight: 500;
            transition: all 0.3s ease;
            z-index: 2;
        }
        /* 图标样式 */
        .header h2 .bi {
            font-size: 1.3rem;
        }

        /* 悬停效果 */
        .header h2:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
        }

        /* 悬停背景效果 */
        .header h2::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.1);
            transform: scaleX(0);
            transform-origin: right;
            transition: transform 0.3s ease;
            z-index: 1;
        }

        .header h2:hover::before {
            transform: scaleX(1);
            transform-origin: left;
        }
        /* 活动状态指示器 */
        .header h2.active {
            background: rgba(255, 255, 255, 0.2);
        }
        .header h2.active::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 70%;
            height: 3px;
            background-color: white;
            border-radius: 3px 3px 0 0;
        }

        .nav-items {
            display: flex;
            gap: 40px;
        }
        /* 用户信息区域 */
        .user-info {
            display: flex;
            align-items: center;
            gap: 15px;
            margin-left: auto;
            position: relative;
        }

        /* 用户头像 */
        .user-avatar {
            width: 42px;
            height: 42px;
            border-radius: 50%;
            object-fit: cover;
            border: 2px solid rgba(255, 255, 255, 0.8);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            cursor: pointer;
        }

        .user-avatar:hover {
            transform: scale(1.05);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
            border-color: white;
        }

        /* 用户名 */
        .username {
            font-weight: 500;
            font-size: 1rem;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
            white-space: nowrap; /* 防止换行 */
            cursor: pointer;
        }

        /* 下拉菜单样式 */
        .dropdown-menu {
            position: absolute;
            top: 100%;
            right: 0;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            min-width: 160px;
            z-index: 1000;
            display: none;
            overflow: hidden;
            margin-top: 10px;
        }

        .dropdown-menu.show {
            display: block;
            animation: fadeIn 0.3s ease;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .dropdown-item {
            padding: 10px 16px;
            color: #333;
            text-decoration: none;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: all 0.2s ease;
        }

        .dropdown-item:hover {
            background-color: #f8f9fa;
            color: #224abe;
        }

        .dropdown-item i {
            font-size: 1rem;
            color: #6c757d;
        }

        .dropdown-item:hover i {
            color: #224abe;
        }

        .dropdown-divider {
            height: 1px;
            background-color: #e9ecef;
            margin: 4px 0;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .header {
                flex-direction: column;
                gap: 10px;
                padding: 15px;
            }

            .header h2 {
                justify-content: center;
                padding: 12px;
            }

            .user-info {
                width: 100%;
                justify-content: center;
                margin-top: 10px;
                padding-top: 10px;
                border-top: 1px solid rgba(255, 255, 255, 0.2);
            }

            .dropdown-menu {
                right: auto;
                left: 50%;
                transform: translateX(-50%);
            }
        }
    </style>
</head>
<body class="bg-light">

<div class="header">
    <div class="nav-items">
        <h2 class="bi bi-people-fill">
            <a href="/volunteer/users/list">用户管理</a>
        </h2>
        <h2 class="bi bi-people-fill">
            <a href="/volunteer/volunteer/list">志愿者管理</a>
        </h2>
        <h2 class="bi bi-people-fill">
            <a href="/volunteer/organization/list">组织管理</a>
        </h2>
        <h2 class="bi bi-people-fill">
            <a href="/volunteer/activityreview">活动审核管理</a>
        </h2>
    </div>

    <div class="user-info">
        <img src="https://picsum.photos/id/1005/40/40"
             class="user-avatar"
             alt="管理员头像"
             id="userAvatar">
        <span class="username" id="username">admin</span>

        <!-- 下拉菜单 -->
        <div class="dropdown-menu" id="dropdownMenu">
            <a href="/volunteer/admin/home" class="dropdown-item">
                <i class="bi bi-house-door"></i> 首页
            </a>
            <div class="dropdown-divider"></div>
            <a href="javascript:void(0);" class="dropdown-item" onclick="logout()">
                <i class="bi bi-box-arrow-right"></i> 退出登录
            </a>
        </div>
    </div>
</div>

<script>
    // 添加活动状态类
    document.addEventListener('DOMContentLoaded', function() {
        const currentPath = window.location.pathname;
        const navItems = document.querySelectorAll('.header h2');

        navItems.forEach(item => {
            const link = item.querySelector('a');
            if (link && currentPath.includes(link.getAttribute('href'))) {
                item.classList.add('active');
            }
        });

        // 头像和用户名点击事件
        const userAvatar = document.getElementById('userAvatar');
        const username = document.getElementById('username');
        const dropdownMenu = document.getElementById('dropdownMenu');

        function toggleDropdown() {
            dropdownMenu.classList.toggle('show');
        }

        userAvatar.addEventListener('click', function(e) {
            e.stopPropagation();
            toggleDropdown();
        });

        username.addEventListener('click', function(e) {
            e.stopPropagation();
            toggleDropdown();
        });

        // 点击页面其他区域关闭下拉菜单
        document.addEventListener('click', function() {
            dropdownMenu.classList.remove('show');
        });

        // 阻止下拉菜单内部点击事件冒泡
        dropdownMenu.addEventListener('click', function(e) {
            e.stopPropagation();
        });
    });

    function logout() {
        if(confirm('确定要退出系统吗？')) {
            // 清除session或token
            // 这里使用简单跳转，实际项目中应该调用退出接口
            window.location.href = '/volunteer/index.jsp'; // 替换为您的登录页路径
        }
    }
</script>
</body>
</html>